<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<button onclick="WebSocketTest()">连接WebSocket</button>
<script>
    function WebSocketTest() {

        if ("WebSocket" in window) {

            for (let i = 0; i < 1; i++) {
                // var ws = new WebSocket("ws://server1.zhidianfan.com:8088/ws");
                var ws = new WebSocket("ws://localhost:10002/ws");
                ws.onopen = function () {
                    // ws.send("哇哈哈");
                    ws.send("{\"tokenId\":\"testToken\",\"action\":1,\"jsonObjStr\":\"{\\\"app\\\":\\\"\\\",\\\"areaCode\\\":\\\"\\\",\\\"clientType\\\":\\\"\\\",\\\"country\\\":\\\"\\\",\\\"group\\\":\\\"\\\",\\\"user\\\":\\\"zln\\\"}\"}");
                };
                ws.onmessage = function (evt) {
                    var received_msg = evt.data;
                    console.log(evt)
                };
            }


        }
    }
</script>
</body>
</html>